﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using CommandLib;

namespace FindArtInfo.Common
{
    public abstract class MultiBase : Controller
    {
        /// <summary>
        /// Invokes the action in the current controller context.
        /// </summary>
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {	                
            string cultureName = string.Empty;
            
            string language = CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE);
            switch (language)
            {
                case "english":
                    cultureName = "en-us";
                    break;
                case "german":
                    cultureName = "de";
                    break;
                case "french":
                    cultureName = "fr";
                    break;
                default:
                    cultureName = "en-us";
                    break;
            }
            
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;            
            return base.BeginExecuteCore(callback, state);
        }
    }
}